package net.oschina.app.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;

import net.oschina.app.R;
import net.oschina.app.ui.adapter.AttentionAdapter;
import net.oschina.app.viewpagerfragment.AttentionFansFragment.AttentionFragment;
import net.oschina.app.viewpagerfragment.AttentionFansFragment.FansFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/4/2.
 */

public class AttentionFansActivity extends AppCompatActivity {

    private ViewPager mViewPager;
    private Toolbar mToolbar;
    private TabLayout mTabLayout;
    public  boolean isFanss = false;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_attention_fans);
        mToolbar = (Toolbar) findViewById(R.id.tb_attention_fans);
        setSupportActionBar(mToolbar);
        mToolbar.setNavigationIcon(R.drawable.actionbar_back_icon_normal);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        mViewPager = (ViewPager) findViewById(R.id.vp_attention_fans);
        mTabLayout = (TabLayout) findViewById(R.id.tl_attention_fans);
        mTabLayout.setupWithViewPager(mViewPager);
        List<Fragment> list = new ArrayList<>();
        AttentionFragment a1 = new AttentionFragment();
        FansFragment f1 = new FansFragment();
        list.add(a1);
        list.add(f1);
        AttentionAdapter adapter = new AttentionAdapter(getSupportFragmentManager(),list);
        mViewPager.setAdapter(adapter);
        mTabLayout.setupWithViewPager(mViewPager);
        isFanss = getIntent().getBooleanExtra("isFans",false);
        if(isFanss) {
            mViewPager.setCurrentItem(1);
        } else {
            mViewPager.setCurrentItem(0);
        }
    }
}
